package com.neusoft.bizcore.notice.system.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.Length;

import com.neusoft.bizcore.notice.system.model.enums.SystemNoticeStatus;
import com.neusoft.bizcore.web.jpa.model.AbstractAuditModel;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Getter
@Setter
@ToString
@Entity
@Table(name = "neuiot_system_notice")
public class SystemNotice extends AbstractAuditModel {
    private static final long serialVersionUID = -2375678914873828135L;

    @NotBlank(message = "应用编码不能为空")
    @Length(max = 32, message = "应用编码不能超过{max}位")
    @Column(length = 32, nullable = true)
    private String appCode;

    @Column(length = 255, nullable = true)
    private String noticeType;

    @Column(length = 255, nullable = true)
    private String noticeRoute;

    @Enumerated(EnumType.STRING)
    @NotNull(message = "通知状态不能为空")
    @Column(length = 32, nullable = false)
    private SystemNoticeStatus isRead = SystemNoticeStatus.unRead;

    //    /** 提醒用户 */
    //    @ManyToMany(targetEntity = NoticeConnectUser.class)
    //    @JoinTable(name = "ref_notice_connect_user", joinColumns = {
    //            @JoinColumn(name = "notice_id", referencedColumnName = "id") }, inverseJoinColumns = {
    //                    @JoinColumn(name = "connect_id", referencedColumnName = "id") })
    //    @LazyCollection(LazyCollectionOption.TRUE)
    //    List<NoticeConnectUser> users;

    @ManyToOne
    NoticeConnectUser user;

    @Length(max = 255, message = "标题不能超过{max}位")
    @Column(length = 255, nullable = true)
    private String title;

    @Length(max = 2047, message = "内容不能超过{max}位")
    @Column(length = 2047, nullable = true)
    private String content;

    @Length(max = 1023, message = "业务信息不能超过{max}位")
    @Column(length = 1023, nullable = true)
    private String businessInfo;

}
